package io.jee.caisan.weixin.domain;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 活动管理
 * 
 * @author xiexx
 *
 */
@Entity
@DynamicUpdate
public class SysActivity {

	/** 点击菜单 */
	public static final Integer TYPE_0 = 0;
	/** 关键字回复 */
	public static final Integer TYPE_1 = 1;
	/** 充值折扣 */
	public static final Integer TYPE_2 = 2;
	/** 活动类型 {0:点击菜单, 1:关键字回复, 2:充值折扣} */
	public static final Map<Integer, String> allTypes = new TreeMap<>();
	static {
		allTypes.put(TYPE_0, "点击菜单");
		allTypes.put(TYPE_1, "关键字回复");
		allTypes.put(TYPE_2, "充值折扣");
	}
	
	/** 不限制  */
	public static final Integer CYCLE_0 = 0;
	/** 仅一次 */
	public static final Integer CYCLE_1 = 1;
	/** 每天一次 */
	public static final Integer CYCLE_2 = 2;
	/** 周期 {0:不限制, 1:仅一次, 2:每天一次} */
	public static final Map<Integer, String> allCycles = new TreeMap<>();
	static {
		allCycles.put(CYCLE_0, "不限制");
		allCycles.put(CYCLE_1, "仅一次");
		allCycles.put(CYCLE_2, "每天一次");
	}

	/** ID */
	private Integer id;
	/** 活动代码，可作为菜单KEY，或者关键字回复等 */
	private String code;
	/** 活动类型 {0:点击菜单, 1:关键字回复, 2:充值折扣} */
	private Integer type;
	/** 开始时间 */
	private Date startTime;
	/** 结束时间 */
	private Date endTime;
	/** 周期 {0:不限制, 1:仅一次, 2:每天一次} */
	private Integer cycle;
	/** 活动内容 例如：双11活动赠送 */
	private String content;
	/** 活动赠送彩豆 
	 * 规则：1.2(固定)，0-1(随机0到1之间取值) */
	private String ruleCaidou;
	/** 活动赠送积分（积分只能取整） 
	 * 规则：2(固定)，0-5(随机0到5之间取值) */
	private String ruleCredit;
	/** 活动赠送经验（经验只能取整） 
	 * 规则：2(固定)，0-5(随机0到5之间取值) */
	private String ruleExp;
	/** 开始之前提示消息 
	 * 文字：text@{content} 
	 * 图文：news@{title}@{description}@{url} */
	private String beforeMessage;
	/** 结束之后提示消息 
	 * 文字：text@{content} 
	 * 图文：news@{title}@{description}@{url} */
	private String afterMessage;
	/** 已参与活动提示消息 
	 * 文字：text@{content} 
	 * 图文：news@{title}@{description}@{url} */
	private String finishMessage;
	/** 参与活动完成提示消息 
	 * 文字：text@{content} 
	 * 图文：news@{title}@{description}@{url} */
	private String completeMessage;
	/** 是否启用（上线或者下线） */
	private boolean enable;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
	
	public Integer getCycle() {
		return cycle;
	}

	public void setCycle(Integer cycle) {
		this.cycle = cycle;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getRuleCaidou() {
		return ruleCaidou;
	}

	public void setRuleCaidou(String ruleCaidou) {
		this.ruleCaidou = ruleCaidou;
	}

	public String getRuleCredit() {
		return ruleCredit;
	}

	public void setRuleCredit(String ruleCredit) {
		this.ruleCredit = ruleCredit;
	}

	public String getRuleExp() {
		return ruleExp;
	}

	public void setRuleExp(String ruleExp) {
		this.ruleExp = ruleExp;
	}

	public String getBeforeMessage() {
		return beforeMessage;
	}

	public void setBeforeMessage(String beforeMessage) {
		this.beforeMessage = beforeMessage;
	}

	public String getAfterMessage() {
		return afterMessage;
	}

	public void setAfterMessage(String afterMessage) {
		this.afterMessage = afterMessage;
	}

	public String getFinishMessage() {
		return finishMessage;
	}

	public void setFinishMessage(String finishMessage) {
		this.finishMessage = finishMessage;
	}

	public String getCompleteMessage() {
		return completeMessage;
	}

	public void setCompleteMessage(String completeMessage) {
		this.completeMessage = completeMessage;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

}
